{extend name="../../admin/view/common/main"/}
{block name="style"}
{include file="../../channel/view/admin/common/style" /}
{/block}
{block name="body"}

<div class="main-title">
    <h2>模板消息配置</h2>
</div>

<div class="with-padding">
    <div class="template-message-edit-section edit-auto-reply" id="template-message">

        <form action="{:url('templateMessage')}" class="form-horizontal ajax-form" method="post">

            <div class="form-item builder_item">
                <label class="item-label">启用状态 <span class="check-tips">是否开启消息通知</span></label>
                <div class="controls">
                    <select name="switch" class="form-control">
                        {if $data['switch'] == 1}
                        <option value="0">关闭</option>
                        <option value="1" selected="">开启</option>
                        {else /}
                        <option value="0" selected="">关闭</option>
                        <option value="1">开启</option>
                        {/if}
                    </select>
                </div>
            </div>

            <div class="form-item builder_item">
                <label class="item-label">消息接收 <span class="check-tips">选择消息接收人</span></label>
                <div class="controls">
                    {if in_array('manager',$data['to'])}
                    <input type="checkbox" name="to[]" value="manager" id="toManager" checked />
                    {else}
                    <input type="checkbox" name="to[]" value="manager" id="toManager" />
                    {/if}
                    <label class="checkbox-inline" for="toManager">管理员</label>

                    {if in_array('user',$data['to'])}
                    <input type="checkbox" name="to[]" value="user" id="toUser" checked />
                    {else}
                    <input type="checkbox" name="to[]" value="user" id="toUser" />
                    {/if}
                    <label class="checkbox-inline" for="toUser">用户</label>
                </div>
            </div>

            <div class="form-item builder_item">
                <label class="item-label">绑定管理员 <span class="check-tips">只能绑定{$element.title}授权的的用户</span></label>
                <div class="controls bind-user">
                    <div id="choose-user-cb">
                        <input type="hidden" name="manager_uid" id="choose-user-uid"
                            value="{$data['manager_info']['uid']|default='0'}">
                        <img src="{$data['manager_info']['avatar64']|default=''}" alt="" id="choose-user-avatar">
                        <span id="choose-user-nickname">{$data['manager_info']['nickname']|default=''}</span>
                    </div>
                    <button type="button" class="btn btn-primary choose-user-btn" data-height="600px"
                        data-name="chooseUserModal"
                        data-iframe="{:url('admin/member/chooseUser',['oauth_type' => $type])}" data-toggle="modal"
                        data-scroll-inside="true">选择管理员</button>
                </div>
            </div>

            {foreach $element.template as $t}
            <div class="form-item builder_item">
                <label class="item-label">{$t.title}</label>
                <div class="controls">
                    <input type="text" class="text input-large form-control" name="tmplmsg[{$t.input_name}]"
                        style="width: 400px" value="{$data['tmplmsg'][$t['input_name']]|default=''}">
                </div>
                <div class="help-block">{$t['tips']}</div>
            </div>
            {/foreach}

            <div class="form-item">
                <label class="item-label"></label>
                <div class="controls">
                    <button type="submit" class="btn submit-btn btn-primary" target-form="form-horizontal">
                        保存
                    </button>
                </div>
            </div>

        </form>
    </div>
</div>
{/block}